Skip to content

[API-373] Add dashboard field flags to create/update#78

Open
callumreid wants to merge 1 commit into
mainfrom
feat/api-373-dashboard-fields
Open

[API-373] Add dashboard field flags to create/update#78
callumreid wants to merge 1 commit into
mainfrom
feat/api-373-dashboard-fields

Conversation

@callumreid
Copy link
Copy Markdown

@callumreid callumreid commented Jun 5, 2026

Summary

coval dashboards create/update only accepted --name. This adds the rest of the dashboard fields the v1 API exposes (paired backend PR coval-ai/backend#4498) so the CLI can fully manage dashboards — including marking one as the organization's default /dashboard.

Linear: API-373

New flags (create + update)

Flag Type Notes
--description string Free-text description
--favorite true/false Mark as favorite
--default true/false Make this the org default (create: omit to auto-default the first dashboard; setting true unsets any other default)
--position integer Ordering position (>= 0)
--config JSON string or @file Free-form config blob

These compose with --input-json like the existing flags. The dashboard response model and --format json output now include description, is_default, is_favorite, position, and config, and the table view gains a DEFAULT column.

Tests

cargo fmt, cargo clippy --all-targets -D warnings, and cargo test all pass. Added two tests asserting the new flags are serialized into the create POST and update PATCH bodies (via body_partial_json) and that responses carrying the new fields parse.

No version bump here — per this repo's convention version bumps land in a separate chore: PR after merge.

Summary by CodeRabbit

  • New Features

    • Dashboards now support additional customization: descriptions, favorite status, default flag, position, and custom configuration for both create and update operations.
  • Documentation

    • Updated example demonstrating dashboard creation with description and default configuration.
  • Tests

    • Added integration tests for new dashboard parameters.

Proof

CI: all 5 platform builds (macOS arm64/x64, Linux arm64/x64, Windows x64) + check green on this PR. Reproduced locally:

fmt + clippycargo fmt --check clean; cargo clippy --all-targets -- -D warnings clean (no warnings).

coval dashboards create --help (new flags wired, booleans constrained to true|false):

Options:
      --name <NAME>
      --description <DESCRIPTION>
      --favorite <FAVORITE>    Mark as a favorite (true/false) [possible values: true, false]
      --default <DEFAULT>      Make this the organization's default dashboard (true/false).
                               Omit to auto-default the first dashboard [possible values: true, false]
      --position <POSITION>    Ordering position (>= 0). Omit to append to the end
      --config <CONFIG>        Free-form JSON config: a JSON string or @path to a file

Testscargo test74 passed; 0 failed. The two new tests assert the flags serialize into the request body (wiremock body_partial_json) and that responses carrying the new fields parse:

test test_dashboard_create_with_full_fields ... ok
test test_dashboard_update_sets_default_and_position ... ok

test_dashboard_create_with_full_fields runs dashboards create --name Ops --description desc --favorite true --default true --position 3 --config '{"date_preferences":{"preset":"last-7-days"}}' and asserts the POST body contains display_name/description/is_favorite/is_default/position/config — a wrong flag→JSON-key mapping (e.g. --default not mapping to is_default) would 404 the mock and fail the test.

Note: a live run against current prod isn't shown because the new fields are server-side-gated on coval-ai/backend#4498 — current prod silently ignores unknown request fields, so a prod run wouldn't actually exercise them until that PR is deployed. End-to-end proof against the real API lands via that PR's post-merge integration suite.

Expose description, is_favorite, is_default, position, and config on
`coval dashboards create` and `coval dashboards update`, plus the same fields
on the dashboard response (with a DEFAULT table column). Mirrors the v1 API
gaining full dashboard field parity.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 5, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

This PR extends the dashboard resource with optional metadata fields. The Dashboard model now supports description, is_default, is_favorite, position, and config. CLI commands for create and update accept these new fields as arguments, serialize them into API payloads, and table output includes a DEFAULT column showing which dashboard is the organization default.

Changes

Dashboard Metadata and Default Status

Layer / File(s) Summary
Dashboard data model and request contracts
src/client/models/dashboard.rs
Dashboard, CreateDashboardRequest, and UpdateDashboardRequest structs extended with optional fields: description, is_default, is_favorite, position, and config. All fields serialize with serde defaults and omit None values.
CLI argument parsing
src/commands/dashboards.rs
CreateArgs and UpdateArgs now declare optional CLI flags for description, favorite, default, position, and config to capture user input from command line.
CLI command execution and JSON serialization
src/commands/dashboards.rs
DashboardCommands::Create and DashboardCommands::Update parse CLI arguments (including config JSON with @file support) and serialize them into API request payloads alongside display_name.
Dashboard table display with default status
src/client/models/dashboard.rs
Tabular implementation for Dashboard adds a DEFAULT column showing "yes" when is_default is true, otherwise empty, preserving existing ID/NAME/CREATED/UPDATED columns.
Integration tests and usage documentation
tests/cli_tests.rs, README.md
Two new integration tests validate create and update request bodies include new fields; README updated with example showing dashboard creation with --description and --default true.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 Dashboard fields now bloom so bright,
With defaults, descriptions, and config delight,
The CLI flags guide users with care,
While tables now show which dashboard to share!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 57.14% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title directly reflects the main changes: adding new field flags (description, favorite, default, position, config) to the dashboard create and update commands.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/api-373-dashboard-fields

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/commands/dashboards.rs`:
- Around line 65-78: Add input validation to enforce position >= 0: implement a
helper fn validate_position(position: Option<i64>) -> Result<()> that returns an
error (e.g., bail!("--position must be >= 0")) when a Some value is negative,
and call validate_position(...) from the Create and Update command handlers
before constructing the request (similar to validate_widget_grid used at lines
~192-204) so negative --position values are rejected client-side with a clear
CLI error.
- Around line 88-101: The position field allows negative values despite the doc
comment; update the dashboard update argument validation to enforce position >=
0 by adding a validator for the position field (the same approach used in
CreateArgs) — either add a clap value parser/range (e.g. value_parser with range
0..) or a small validate() check in the UpdateArgs handling path that returns an
error when position < 0; target the position field in the dashboards.rs
UpdateArgs/struct and mirror the CreateArgs validation logic so negatives are
rejected.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 58efad1a-2da8-4700-ad81-1103d18cfb44

📥 Commits

Reviewing files that changed from the base of the PR and between 1ef8f68 and 52d1460.

📒 Files selected for processing (4)
  • README.md
  • src/client/models/dashboard.rs
  • src/commands/dashboards.rs
  • tests/cli_tests.rs

Comment on lines +65 to +78
#[arg(long)]
description: Option<String>,
/// Mark as a favorite (true/false).
#[arg(long)]
favorite: Option<bool>,
/// Make this the organization's default dashboard (true/false). Omit to auto-default the first dashboard.
#[arg(long)]
default: Option<bool>,
/// Ordering position (>= 0). Omit to append to the end.
#[arg(long)]
position: Option<i64>,
/// Free-form JSON config: a JSON string or @path to a file.
#[arg(long)]
config: Option<String>,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Add validation for position >= 0.

The doc comment at line 73 states position should be ">= 0", but there's no validation to enforce this constraint before sending the request. Users providing negative values will receive an API error instead of a clear, immediate CLI error.

Consider adding a validation helper similar to validate_widget_grid (lines 192-204):

fn validate_position(position: Option<i64>) -> Result<()> {
    if let Some(p) = position {
        if p < 0 {
            bail!("--position must be >= 0");
        }
    }
    Ok(())
}

Then call it in the Create and Update handlers before building the request.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/commands/dashboards.rs` around lines 65 - 78, Add input validation to
enforce position >= 0: implement a helper fn validate_position(position:
Option<i64>) -> Result<()> that returns an error (e.g., bail!("--position must
be >= 0")) when a Some value is negative, and call validate_position(...) from
the Create and Update command handlers before constructing the request (similar
to validate_widget_grid used at lines ~192-204) so negative --position values
are rejected client-side with a clear CLI error.

Comment on lines +88 to +101
#[arg(long)]
description: Option<String>,
/// Mark as a favorite (true/false).
#[arg(long)]
favorite: Option<bool>,
/// Make this the organization's default dashboard (true/false). Setting true unsets any other default.
#[arg(long)]
default: Option<bool>,
/// Ordering position (>= 0).
#[arg(long)]
position: Option<i64>,
/// Replacement free-form JSON config: a JSON string or @path to a file.
#[arg(long)]
config: Option<String>,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Add validation for position >= 0.

Same issue as CreateArgs: the doc comment at line 96 specifies ">= 0" but no validation is present.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/commands/dashboards.rs` around lines 88 - 101, The position field allows
negative values despite the doc comment; update the dashboard update argument
validation to enforce position >= 0 by adding a validator for the position field
(the same approach used in CreateArgs) — either add a clap value parser/range
(e.g. value_parser with range 0..) or a small validate() check in the UpdateArgs
handling path that returns an error when position < 0; target the position field
in the dashboards.rs UpdateArgs/struct and mirror the CreateArgs validation
logic so negatives are rejected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant